package com.company.managesystem.activity;

import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.company.managesystem.R;
import com.company.managesystem.service.UpdateChecker;
import com.company.managesystem.util.SharePreferenceUtil;

/**
 * 首页
 * Created by lqy on 2017/6/29.
 */

public class MainActivity extends BaseActivity {

    private RelativeLayout unfinished_layout, repairing_layout, finished_layout, evaluate_layout,setup_layout;
    private TextView nameText, departmentText;
    private UpdateChecker updateChecker;

    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void initView() {
//        updateChecker.setCheckUrl("");
//        updateChecker.checkForUpdates();
        setMainActivityFlag(true);
        setToolBarTitle("后勤综合管理平台");
        nameText = (TextView) findViewById(R.id.main_name_text);
        departmentText = (TextView) findViewById(R.id.main_department_text);
        unfinished_layout = (RelativeLayout) findViewById(R.id.unfinshed_layout);
        repairing_layout = (RelativeLayout) findViewById(R.id.repairing_layout);
        finished_layout = (RelativeLayout) findViewById(R.id.finished_layout);
        evaluate_layout = (RelativeLayout) findViewById(R.id.evaluate_layout);
        setup_layout = (RelativeLayout) findViewById(R.id.setup_layout);
    }

    @Override
    protected void initData() {
        nameText.setText(new SharePreferenceUtil(this).getName());
        departmentText.setText(new SharePreferenceUtil(this).getDepartment());
        unfinished_layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, CommonListActivity.class);
                intent.putExtra("flag", "1");
                startActivity(intent);
            }
        });
        repairing_layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, CommonListActivity.class);
                intent.putExtra("flag", "2");
                startActivity(intent);
            }
        });
        finished_layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, CommonListActivity.class);
                intent.putExtra("flag", "3");
                startActivity(intent);
            }
        });
        evaluate_layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(MainActivity.this, "评价功能暂未开放，敬请期待！", Toast.LENGTH_SHORT).show();
//                Intent intent = new Intent(MainActivity.this, CommonListActivity.class);
//                intent.putExtra("flag", "4");
//                startActivity(intent);
            }
        });
        setup_layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, ChangePwdActivity.class);
                startActivity(intent);
//                Toast.makeText(MainActivity.this, "系统设置暂未开放，敬请期待！", Toast.LENGTH_SHORT).show();
            }
        });
    }

}
